#include "wx/wx.h"
#include "wx/ogl/ogl.h"
#ifndef STATEMACHINE_H
#define STATEMACHINE_H

class wxShapeSelectChangeEvent : public wxNotifyEvent
{
public:
 wxShapeSelectChangeEvent(wxShape*s,wxEventType commandType = wxEVT_NULL,
			     int id = 0): wxNotifyEvent(commandType, id){
	shape = s;
    }
 wxShapeSelectChangeEvent():wxNotifyEvent(){
	shape=NULL;
    }
    wxShapeSelectChangeEvent(const wxShapeSelectChangeEvent& event): wxNotifyEvent(event)  {
	shape = event.shape;
    }
    virtual wxEvent *Clone() const{ 
	return new wxShapeSelectChangeEvent(*this); 
    }
    wxShape *shape;
    DECLARE_DYNAMIC_CLASS(wxShapeSelectChangeEvent);
};

typedef void (wxEvtHandler::*wxShapeSelectChangeEventFunction)(wxShapeSelectChangeEvent&);

BEGIN_DECLARE_EVENT_TYPES()
    DECLARE_EVENT_TYPE(wxEVT_COMMAND_SHAPE_SELECT_CHANGED, -1)
END_DECLARE_EVENT_TYPES()

//extern const wxEventType wxEVT_COMMAND_SHAPE_SELECT_CHANGED;
//const wxEventType wxEVT_COMMAND_SHAPE_SELECT_CHANGED = wxNewEventType();

#define EVT_SHAPE_SELECT_CHANGED(id, fn) \
    DECLARE_EVENT_TABLE_ENTRY(\
			      wxEVT_COMMAND_SHAPE_SELECT_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) \
    (wxShapeSelectChangeEventFunction) & fn,(wxObject *) NULL ),

class StateMachine: public wxShapeCanvas
{
// DECLARE_DYNAMIC_CLASS(wxShapeCanvas)
 protected:
 public:
  StateMachine(wxWindow *parent = NULL, wxWindowID id = wxID_ANY,
            const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
	       long style = wxRETAINED):wxShapeCanvas(parent,id,pos,size,style){};
  ~StateMachine(void){};
  void OnSelectShape(wxShape*s);
  void OnPaint(wxPaintEvent& event);
  DECLARE_EVENT_TABLE()
};


class MyEvtHandler: public wxShapeEvtHandler
{
 public:
  wxString label;
  MyEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL, const wxString& lab = wxEmptyString):wxShapeEvtHandler(prev, shape)
  {
    label = lab;
  }
  ~MyEvtHandler(void)
  {
  }
  void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
  void OnEndSize(double x, double y);
};


#endif
